#include <iostream>
#include <string>
#include <vector>

using namespace std;

class Solution
{
public:
    int rangeBitwiseAnd(int m, int n)
    {
        if(m==n)
            return m;
        int x=spite(n);
        if(x==0)
            return 0;
        if(x>m)
            return 0;
        if(x==n)
            return 0;
        if(x==m)
            return x;
        if(x<m)
            return x|rangeBitwiseAnd(m&(x-1),n&(x-1));

        return 0;
    }

    int spite(int n)
    {
        int x=0x1;
        int result=0;
        while(x!=0)
            {
                if((x&n)>0)
                    result=x&n;
                x<<=1;
            }
        return result;
    }
};

int main()
{
    Solution s;

    int m,n;
    while(true)
        {
            cin>>m>>n;
            cout<<s.rangeBitwiseAnd(m,n)<<endl;
        }
}